Skip to content

Add TyCtxt::is_lang_item, use it in the compiler #126491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 15, 2024

Conversation

compiler-errors
Copy link
Member

pub fn is_lang_item(self, def_id: DefId, lang_item: LangItem) -> bool;

Easier than having to use Some(def_id) == tcx.lang_items().iterator_trait() or something. Also makes it easier to turn into TraitSolverLangItem in the future. Hope it's not too bad for perf.

r? @lcnr or @oli-obk

@compiler-errors
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 14, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 14, 2024

Some changes occurred in match lowering

cc @Nadrieril

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in compiler/rustc_sanitizers

cc @rust-lang/project-exploit-mitigations, @rcvalle

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 14, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 14, 2024
Add `TyCtxt::is_lang_item`, use it in the compiler

```rust
pub fn is_lang_item(self, def_id: DefId, lang_item: LangItem) -> bool;
```

Easier than having to use `Some(def_id) == tcx.lang_items().iterator_trait()` or something. Also makes it easier to turn into `TraitSolverLangItem` in the future. Hope it's not too bad for perf.

r? `@lcnr` or `@oli-obk`
@bors
Copy link
Collaborator

bors commented Jun 14, 2024

⌛ Trying commit 266754c with merge 0ad747e...

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jun 14, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 14, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Jun 14, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 14, 2024
Add `TyCtxt::is_lang_item`, use it in the compiler

```rust
pub fn is_lang_item(self, def_id: DefId, lang_item: LangItem) -> bool;
```

Easier than having to use `Some(def_id) == tcx.lang_items().iterator_trait()` or something. Also makes it easier to turn into `TraitSolverLangItem` in the future. Hope it's not too bad for perf.

r? `@lcnr` or `@oli-obk`
@bors
Copy link
Collaborator

bors commented Jun 14, 2024

⌛ Trying commit 93ff86e with merge be24883...

@oli-obk
Copy link
Contributor

oli-obk commented Jun 14, 2024

In my ideal world we'd be able to preregister def ids like we do with symbols, so lang items can be constant def ids that we can match on (instead of having if/elseif chains), but I don't know how to get there yet in a non-hacky way.

Something like this is preferrable. If perf is an issue, maybe a macro to hide the boilerplate would work, too?

@bors
Copy link
Collaborator

bors commented Jun 14, 2024

☀️ Try build successful - checks-actions
Build commit: be24883 (be248837ad9f9bbeed1e754e9c4f4d54333323d4)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (be24883): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.4%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.4%] 7

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 671.997s -> 672.355s (0.05%)
Artifact size: 320.43 MiB -> 319.79 MiB (-0.20%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 15, 2024
@compiler-errors
Copy link
Member Author

That's barely anything lol

@oli-obk
Copy link
Contributor

oli-obk commented Jun 15, 2024

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 15, 2024

📌 Commit 93ff86e has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 15, 2024
@bors
Copy link
Collaborator

bors commented Jun 15, 2024

⌛ Testing commit 93ff86e with merge 8217b41...

@bors
Copy link
Collaborator

bors commented Jun 15, 2024

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 8217b41 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 15, 2024
@bors bors merged commit 8217b41 into rust-lang:master Jun 15, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 15, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8217b41): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.4%] 10
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.4%] 10

Max RSS (memory usage)

Results (primary -2.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.2% [-2.2%, -2.2%] 1

Cycles

Results (secondary 8.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
8.7% [7.8%, 9.3%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (secondary -0.0%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 1
All ❌✅ (primary) - - 0

Bootstrap: 671.712s -> 671.15s (-0.08%)
Artifact size: 320.45 MiB -> 319.77 MiB (-0.21%)

@rylev
Copy link
Member

rylev commented Jun 20, 2024

That's barely anything lol

I assume this means that the regressions that were seen aren't considered severe enough.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants